<template>
  <div>
    <!-- 全局注册过的小盒子 -->
    <ul>
      <li v-for="(item, index) in shopList" :key="index" @click="$router.push(`/details?id=${item.product_id}`)">
        <img
          :src="'http://106.15.179.105:3000/' + item.product_picture"
          alt=""
        />
        <h2>{{ item.product_name }}</h2>
        <span class="span">{{ item.product_title }} </span>
        <p>
          <span>{{ item.product_selling_price }}元</span>
          <del v-if="item.product_selling_price != item.product_price"
            >{{ item.product_price }}元</del
          >
        </p>
      </li>
      <li class="second" v-if="!More"  @click="toGoods">
        <router-link to="">
          <a href="">浏览更多<i class="el-icon-d-arrow-right"></i></a>
        </router-link>
        
      </li>
    </ul>
  </div>
</template>

<script>
export default {
  name: "MList",
  props: ["shopList","More"], //接收父组件传过来的值
  data() {
    return {
     
    };
  },

  components: {},
  mounted() {},
  methods: {
     toGoods(){
      // alert(11)
      let list = [];
      this.shopList.forEach(item=>{
        console.log(item)
        list.push(item.category_id)
        
      })

      function data(arr){
        return [...new Set(arr)];
      }
      let arr = data(list);
      console.log(arr);
      this.$router.push({path:'/allShop',query:arr})
    }
  },
  computed: {},
  watch: {},
};
</script>

<style lang='scss' scoped>
ul {
  display: flex;
  width: 100%;
  flex-wrap: wrap;
  text-align: center;
  align-items: center;
  li {
    width: 234px;
    height: 300px;
    background: white;
    margin: 0px 0px 20px 13.7px;
    list-style: none;
    padding: 20px 0;
    display: block;
    img {
      width: 160px;
      height: 160px;
      
    }
  
    h2 {
      margin: 25px 10px 0;
      font-size: 14px;
      color: #333;
      font-weight: 400;
      text-align: center;
      text-overflow: ellipsis;
      white-space: nowrap;
      overflow: hidden;
    }
    .span {
      display: block;
      height: 18px;
      font-size: 12px;
      color: #b0b0b0;
      margin: 5px 10px;
    }
    p {
      span {
        text-align: center;
        color: #ff6700;
        font-size: 16px;
      }
      del {
        margin-left: 8px;
        color: #b0b0b0;
      }
    }
  }
  .second {
    line-height: 300px;
    a {
      text-decoration: none;
    }
  }
  li:hover {
    transform: translateY(-5px);
    transition: 0.2s all;
    box-shadow: 1px 1px 20px 3px rgb(216, 211, 211);
  }
}
</style>
